<!DOCTYPE html>
<html
  xmlns:th="http://www.thymeleaf.org"
  xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>AI 面试 系统 - 开始面试吧</title>
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css"
      rel="stylesheet"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css"
    />
  </head>
  <body>
    <nav
      class="navbar navbar-expand-lg navbar-dark"
      style="
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      "
    >
      <div class="container">
        <a class="navbar-brand d-flex align-items-center" href="#">
          <i class="bi bi-robot me-2" style="font-size: 1.5rem"></i>
          AI 面试系统
        </a>
        <button
          class="navbar-toggler border-0"
          type="button"
          data-bs-toggle="collapse"
          data-bs-target="#navbarNav"
        >
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav ms-auto">
            <li class="nav-item">
              <span class="nav-link d-flex align-items-center">
                <i class="bi bi-person-circle me-2"></i>
                欢迎, [[${#authentication?.principal?.username ?: '游客'}]]
              </span>
            </li>
            <li class="nav-item">
              <a
                class="nav-link d-flex align-items-center"
                th:href="@{/interviews}"
              >
                <i class="bi bi-list-ul me-2"></i>我的面试
              </a>
            </li>
            <li class="nav-item" sec:authorize="hasRole('ADMIN')">
              <a
                class="nav-link d-flex align-items-center"
                th:href="@{/admin/users}"
              >
                <i class="bi bi-people me-2"></i>用户管理
              </a>
            </li>
            <li class="nav-item">
              <a
                class="nav-link d-flex align-items-center"
                th:href="@{/logout}"
              >
                <i class="bi bi-box-arrow-right me-2"></i>登出
              </a>
            </li>
          </ul>
        </div>
      </div>
    </nav>

    <div class="container mt-4">
      <div class="row">
        <div class="col-lg-10 offset-lg-1">
          <div
            class="card shadow-lg border-0"
            style="border-radius: 20px; overflow: hidden"
          >
            <div
              class="card-header text-white"
              style="
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                border: none;
              "
            >
              <div class="d-flex align-items-center">
                <i
                  class="bi bi-rocket-takeoff me-3"
                  style="font-size: 2rem"
                ></i>
                <div>
                  <h4 class="mb-1">开始您的AI面试</h4>
                  <p class="mb-0 opacity-75">智能评估，精准匹配，助您成功</p>
                </div>
              </div>
            </div>
            <div class="card-body p-5">
              <div class="row mb-5">
                <div class="col-lg-8">
                  <div class="d-flex align-items-start mb-4">
                    <div
                      class="bg-primary bg-opacity-10 rounded-circle p-3 me-3"
                    >
                      <i
                        class="bi bi-cpu text-primary"
                        style="font-size: 1.5rem"
                      ></i>
                    </div>
                    <div>
                      <h5 class="text-primary mb-2">AI智能面试系统</h5>
                      <p class="text-muted mb-0">
                        上传您的简历，我们的AI将根据您的经验和目标职位，生成个性化的面试问题。
                        支持PDF和Word文档，或直接粘贴简历文本。
                      </p>
                    </div>
                  </div>

                  <div class="row g-3">
                    <div class="col-md-6">
                      <div
                        class="d-flex align-items-center p-3 bg-light rounded-3"
                      >
                        <i
                          class="bi bi-file-earmark-pdf text-danger me-3"
                          style="font-size: 1.5rem"
                        ></i>
                        <div>
                          <h6 class="mb-1">支持PDF格式</h6>
                          <small class="text-muted">自动解析简历内容</small>
                        </div>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div
                        class="d-flex align-items-center p-3 bg-light rounded-3"
                      >
                        <i
                          class="bi bi-file-earmark-word text-primary me-3"
                          style="font-size: 1.5rem"
                        ></i>
                        <div>
                          <h6 class="mb-1">支持Word格式</h6>
                          <small class="text-muted">智能提取关键信息</small>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-4">
                  <div class="card bg-gradient-light border-0 shadow-sm h-100">
                    <div class="card-body text-center">
                      <i
                        class="bi bi-list-ol text-primary mb-3"
                        style="font-size: 2rem"
                      ></i>
                      <h6 class="card-title text-primary">面试流程</h6>
                      <div class="text-start">
                        <div class="d-flex align-items-center mb-3">
                          <div
                            class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center me-3"
                            style="width: 30px; height: 30px; font-size: 0.8rem"
                          >
                            1
                          </div>
                          <small class="text-muted">上传简历</small>
                        </div>
                        <div class="d-flex align-items-center mb-3">
                          <div
                            class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center me-3"
                            style="width: 30px; height: 30px; font-size: 0.8rem"
                          >
                            2
                          </div>
                          <small class="text-muted">AI生成问题</small>
                        </div>
                        <div class="d-flex align-items-center mb-3">
                          <div
                            class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center me-3"
                            style="width: 30px; height: 30px; font-size: 0.8rem"
                          >
                            3
                          </div>
                          <small class="text-muted">回答问题</small>
                        </div>
                        <div class="d-flex align-items-center">
                          <div
                            class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center me-3"
                            style="width: 30px; height: 30px; font-size: 0.8rem"
                          >
                            4
                          </div>
                          <small class="text-muted">获得评估</small>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              <div
                th:if="${errorMessage}"
                class="alert alert-danger mb-4 d-flex align-items-center"
              >
                <i class="bi bi-exclamation-triangle me-2"></i>
                [[${errorMessage}]]
              </div>

              <div
                th:if="${successMessage}"
                class="alert alert-success mb-4 d-flex align-items-center"
              >
                <i class="bi bi-check-circle me-2"></i> [[${successMessage}]]
              </div>

              <form
                th:action="@{/interview/start}"
                method="post"
                enctype="multipart/form-data"
                class="needs-validation"
                novalidate
              >
                <div class="mb-4">
                  <label
                    for="jobPosition"
                    class="form-label fw-semibold d-flex align-items-center"
                  >
                    <i class="bi bi-briefcase me-2 text-primary"></i>
                    目标职位 <span class="text-danger ms-1">*</span>
                  </label>
                  <select
                    class="form-select form-select-lg"
                    id="jobPosition"
                    name="jobPosition"
                    required
                    style="border-radius: 10px; border: 2px solid #e9ecef"
                  >
                    <option value="">请选择职位</option>
                    <option value="软件工程师">软件工程师</option>
                    <option value="前端开发工程师">前端开发工程师</option>
                    <option value="后端开发工程师">后端开发工程师</option>
                    <option value="全栈开发工程师">全栈开发工程师</option>
                    <option value="Java开发工程师">Java开发工程师</option>
                    <option value="Python开发工程师">Python开发工程师</option>
                    <option value="产品经理">产品经理</option>
                    <option value="UI/UX设计师">UI/UX设计师</option>
                    <option value="数据分析师">数据分析师</option>
                    <option value="市场营销经理">市场营销经理</option>
                    <option value="销售经理">销售经理</option>
                    <option value="人力资源专员">人力资源专员</option>
                    <option value="财务分析师">财务分析师</option>
                    <option value="项目经理">项目经理</option>
                    <option value="其他">其他</option>
                  </select>
                  <div class="form-text">
                    <i class="bi bi-info-circle me-1"></i>
                    选择最符合您求职目标的职位
                  </div>
                </div>

                <div class="mb-5">
                  <label
                    class="form-label fw-semibold d-flex align-items-center mb-3"
                  >
                    <i class="bi bi-file-earmark-text me-2 text-primary"></i>
                    简历信息
                  </label>

                  <div class="row g-4">
                    <div class="col-md-6">
                      <div
                        class="card border-2 border-dashed border-primary h-100"
                        style="border-radius: 15px"
                      >
                        <div class="card-body text-center p-4">
                          <i
                            class="bi bi-cloud-upload text-primary mb-3"
                            style="font-size: 2.5rem"
                          ></i>
                          <h6 class="text-primary mb-2">上传简历文件</h6>
                          <p class="text-muted small mb-3">
                            支持 PDF 和 DOCX 格式
                          </p>
                          <input
                            class="form-control"
                            type="file"
                            id="resumeFile"
                            name="resumeFile"
                            accept=".pdf,.docx"
                            style="border-radius: 10px"
                          />
                        </div>
                      </div>
                    </div>

                    <div class="col-md-6">
                      <div
                        class="card border-2 border-light h-100"
                        style="border-radius: 15px"
                      >
                        <div class="card-body p-4">
                          <div class="d-flex align-items-center mb-3">
                            <i class="bi bi-type text-primary me-2"></i>
                            <h6 class="text-primary mb-0">或粘贴简历文本</h6>
                          </div>
                          <textarea
                            class="form-control"
                            id="resumeText"
                            name="resumeText"
                            rows="8"
                            placeholder="将您的简历内容粘贴在这里..."
                            style="
                              border-radius: 10px;
                              border: 2px solid #e9ecef;
                              resize: none;
                            "
                          ></textarea>
                        </div>
                      </div>
                    </div>
                  </div>

                  <div class="text-center mt-3">
                    <small class="text-muted">
                      <i class="bi bi-info-circle me-1"></i>
                      请选择其中一种方式提供简历信息
                    </small>
                  </div>
                </div>

                <div class="d-grid">
                  <button
                    type="submit"
                    class="btn btn-primary btn-lg py-3"
                    style="
                      background: linear-gradient(
                        135deg,
                        #667eea 0%,
                        #764ba2 100%
                      );
                      border: none;
                      border-radius: 15px;
                      font-weight: 600;
                    "
                  >
                    <i class="bi bi-play-circle me-2"></i>
                    开始AI面试
                  </button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
    <script>
      // Simple script to ensure either file or text is provided
      document.querySelector("form").addEventListener("submit", function (e) {
        const fileInput = document.getElementById("resumeFile");
        const textInput = document.getElementById("resumeText");

        if (fileInput.files.length === 0 && !textInput.value.trim()) {
          e.preventDefault();
          alert("请通过上传文件或粘贴文本来提供您的简历。");
        }
      });
    </script>
  </body>
</html>
